jQuery(document).ready(function() {
	
	/**
	 * ========================================================================
	 * jQuery rating stars
	 * ========================================================================
	 */
	
	$('.image-rating').rating(); 
	
	$('.rating-stars-filter-auto-submit').rating({
		callback: function(value, link){
		// 'this' is the hidden form element holding the current value
		// 'value' is the value selected
		// 'element' points to the link element that received the click.
		alert("The value selected was '" + value + 
			  "'\n\nWith this callback function I can automatically submit the form");

		// To submit the form automatically:
		//this.form.submit();
		
		// To submit the form via ajax:
		//$(this.form).ajaxSubmit();
		}
	});
	

	/**
	 * ========================================================================
	 * jQuery user forms
	 * ========================================================================
	 */
	
	// TODO: LME - Implement CRSF solution to send ajax forms.
	// http://aymsystems.com/ajax-csrf-protection-codeigniter-20
	
//	$( "#user-login-button" )
//	.click(function() {
//		$( "#login-form" ).dialog( "open" );
//	});
//	
//	$( "#user-registration-button" )
//		.click(function() {
//			$( "#registration-form" ).dialog( "open" );
//	});
	
	
/**
 * ========================================================================
 * jQuery carousel
 * ========================================================================
 */
	
	jQuery('.carousel-line-1').jcarousel({
		auto: 10,
		wrap: 'circular',
		initCallback: mycarousel_initCallback
	});
	
	jQuery('.carousel-line-2').jcarousel({
			auto: 10,
			wrap: 'circular',
			initCallback: mycarousel_initCallback
	});	
	
	function mycarousel_initCallback(carousel)
	{
		// Disable autoscrolling if the user clicks the prev or next button.
		/*carousel.buttonNext.bind('click', function() {
			carousel.startAuto(0);
		});

		carousel.buttonPrev.bind('click', function() {
			carousel.startAuto(0);
		});*/

		// Pause autoscrolling if the user moves with the cursor over the clip.
		carousel.clip.hover(function() {
			carousel.stopAuto();
		}, function() {
			carousel.startAuto();
		});
	};

});

